#include<stdio.h>
#include<stdlib.h>

#include "FuncStruct.h"
#include <stdlib.h>
extern int count;

int color[8];
main()
{
	int flag;
	int i,j;
	int turn=0;
	

	Info *conf=(Info*)malloc(sizeof(Info));
	LinkQueue Q;
	MapTurn mapTurn;

	ReadInfo(conf);


	mapTurn.map = *conf;
	mapTurn.turn[0] = -1;

	InitQueue(&Q);
	EnQueue(&Q, mapTurn);
	SearchCentre(mapTurn.map, color);
for(i=0; i<MAX_NUM; i++)
{

	flag = TraverseTree(&mapTurn, &Q);
	if(flag >= 0)
		break;

}

if(flag == 1)
	printf("SUCCEESS!\n");
else
	printf("FAIL!\n");

	for(i=0; i<mapTurn.map.matrixN; i++)
	{
		for(j=0; j<mapTurn.map.matrixN; j++)
		{
			printf("%d", mapTurn.map.matrixArr[i][j]);
			if(j < mapTurn.map.matrixN-1)
			{
				printf(",");
			}
		}
		printf("\n");
	}

	printf("\n");
	j=0;
	for(i=0; i<GetPosition(mapTurn.turn); i++)
	{
		printf("%d", mapTurn.turn[i]);
		if((i+1)%4 !=0)
			printf(",");
		j++;
		if(j==4)
		{
			printf("\n");
			j=0;
			turn ++;
		}

	}
	printf("turn   :\n%d\n", turn);
		printf("count :\n%d\n", count);
	PrintColourValue(mapTurn.map);
	printf("SUM    : %d\n", JudgeColorValue(mapTurn.map));
	OutputResult(mapTurn.turn);
    system("pause");
}
